import { _decorator, Component, instantiate, Node, Prefab, UITransform } from 'cc';
import { bridgeController } from './bridgeController';
const { ccclass, property } = _decorator;

@ccclass('bridegsRootController')
export class bridegsRootController extends Component {
    @property(Prefab) bridge:Prefab
    start() 
    {

    }
    init()
    {

    }

    createBridge()
    {
        const piers = this.node.parent.getChildByName("piersRoot").children
        const x = piers[piers.length - 2].getPosition().x + piers[piers.length - 2].getComponent(UITransform).width - 5
        const y = piers[piers.length - 2].getPosition().y + piers[0].getComponent(UITransform).contentSize.height
        const bridge = instantiate(this.bridge);
        this.node.addChild(bridge);
        bridge.setPosition(x,y)
    }
    UpOk()
    {
        const chi = this.node.children
        chi[chi.length - 1].getComponent(bridgeController).UpOk();
    }
    update(deltaTime: number) 
    {
        
    }
}


